//
//  E7GameLayer.h
//  e7engine
//
//  Created by cc on 12-3-13.
//  Copyright (c) 2012年 PalmGame. All rights reserved.
//

#ifndef e7engine_E7GameLayer_h
#define e7engine_E7GameLayer_h

#include "E7GameDefine.h"

#include "E7GameChildLayer.h"
#include "E7OpenGLLayer.h"
#include "E7DialogLayer.h"
#include "E7HelpLayer.h"

class  CE7GameLayer : public CE7Layer
{
private:
    typedef enum
    {
        DS_NONE = 0,
        DS_TURNEND,
        DS_LOSE,
        DS_UNDO,
        DS_GAMEEND,
        DS_NEXT,
        DS_CONTINUE,
        DS_RETRY,
    } eDialogState ;
    eDialogState    m_eDS ;
public:
    CE7GameLayer() ;
    ~CE7GameLayer() ;

    void CreateRandomMap() ;
    void ClickedLose() ;
    void ClickedHelp() ;
    void ClickedTurnEnd() ;
//    void ClickedUndo() ;
    void ClickedCreateSoldier() ;
    void ClickedCreateTower() ;

public:
    //    virtual void draw() ;
    virtual bool Loop() ;

    virtual void DialogYES() ;
    virtual void DialogNO() ;
    virtual void DialogOK() ;

	virtual void ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent) ;
	virtual void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent) ;
	virtual void ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent) ;
	virtual void ccTouchesCancelled(CCSet *pTouches, CCEvent *pEvent) ;

    void SetPreviewMode() ;
    void SetGameMode() ;

private:
    CCLayer*             m_pInfoLayer ;
    CCMenu*              m_pInfoMenus ;
    CCMenuItem*          m_pSoldierItem ;
    CCMenuItem*          m_pTowerItem ;
    CCSprite*            m_pSoldierNumber[2] ;
    CCSprite*            m_pSoldierOperation ;
    CCSprite*            m_pTowerNumber[2] ;
    CCSprite*            m_pTowerOperation ;

//    CCLabelTTF*          m_pLabelTurnCount ;
//    CCLabelTTF*          m_pLabelTurnID ;

    void InitCreateInfo() ;
    void ShowInfoLayer() ;
    void HideInfoLayer() ;
    void UpdateTurnInfo(int turnid, int turncount) ;

private:
    CE7Layer*            m_pBackLayer ;
    CCLayer*             m_pUILayer ;
    CE7Sprite*           m_pBorderSprite ;
    CCMenu*              m_pBorderButtons ;
    CCMenuItem*          m_pButtonLose ;
    CCMenuItem*          m_pButtonHelp ;
    CCMenuItem*          m_pButtonMenu ;
    CCMenuItem*          m_pButtonTurnEnd ;

private:
    CCSpriteBatchNode*   m_pTurnIDSheet ;
    CCSpriteBatchNode*   m_pTurnCountSheet ;
    CCSprite*            m_pYourTurnSprite ;
    CCSprite*            m_pEnemyTurnSprite ;
    CCSprite*            m_pTurnCountSprite ;
    CCSprite*            m_pTurnIDSprite ;

public:
    CE7DialogLayer*      m_pDialogLayer ;

    CE7ZoomLayer*        m_pZoomLayer ;
    CE7GameChildLayer*   m_pGameChildLayer ;

    CE7OpenGLLayer*      m_pOpenGLLayer ;

    CE7HelpLayer*        m_pHelpLayer ;

private:
    CCRect               m_rcNumberNone[10] ;
    CCRect               m_rcNumberGold[10] ;
    CCRect               m_rcOperation[4] ;

    CCSpriteBatchNode*   m_pNumberNoneSheet ;
    CCSpriteBatchNode*   m_pOperationSheet ;
    CCSpriteBatchNode*   m_pNumberGoldSheet ;
    CCSpriteBatchNode*   m_pNumberInGoldSheet ;

    CCSprite*            m_pSelSoldier ;
    CCSprite*            m_pSelTower ;

    CCSprite*            m_pOperationGold[2] ;
    CCSprite*            m_pOperationInGold[2] ;
};

extern CE7GameLayer* s_pGameLayer ;

#endif















